﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class Admin_ChatsExpert : System.Web.UI.Page
{
	private string strExpertSessionID = "";
	private PX.Chat.ChatComponent clsChatComp = new PX.Chat.ChatComponent();
	private PX.OnLine.OnLineComponent clsOnLineComp = new PX.OnLine.OnLineComponent();
	private string strQuestionSessionID = "";		// 专家要回答的提问者SessionID
	private int nExpertUserID = 0;
	private PX.Config clsConfig = new PX.Config();

	protected override void OnInit(EventArgs e)
	{
		base.OnInit(e);

		strExpertSessionID = Session.SessionID.ToString();

		idBody.Attributes.Add("onload", "goButtom('" + pChats.ClientID.ToString() + "')");
	}

	protected void Page_Load(object sender, EventArgs e)
	{
		ShowChat();
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>
	/// 显示登录专家交流记录
	/// </summary>
	private void ShowChat()
	{
		List<PX.Chat.Chat> listChats = new List<PX.Chat.Chat>();

		listChats = clsChatComp.QueryExpertChats(strExpertSessionID);
		for (int i = 0; i < listChats.Count; i++)
		{
			TextBox txtChat = new TextBox();
			Panel pChat = new Panel();
			Panel pChatStatus = new Panel();
			Label labStatus = new Label();

			PX.OnLine.OnLine clsQuestion = new PX.OnLine.OnLine();

			labStatus.CssClass = "Public_OneChatTitle";
			pChat.CssClass = "Public_OneChat";
			txtChat.CssClass = "Public_OneChatContent";

			txtChat.TextMode = TextBoxMode.MultiLine;

			clsQuestion = clsOnLineComp.Query(listChats[i].QuestionSession);

			if (clsQuestion != null)
			{
				if (listChats[i].QorA == clsConfig.nChat_Question)
				{
					labStatus.Text = clsQuestion.Name + "对您说";
				}
				else
				{
					labStatus.Text = "您对" + clsQuestion.Name + "说";
				}
			}
			
			txtChat.Text = listChats[i].Chats;

			pChat.Controls.Add(labStatus);
			pChat.Controls.Add(txtChat);

			pChats.Controls.Add(pChat);
		}
	}
	////////////////////////////////////////////////////////////////////////////////////////////////////
}
